using D.Medicalcare.ErrorCode;
using D.Medicalcare.Write.API.Application.Commands.PackageTypeCommand;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace D.Medicalcare.Write.API.Controllers
{
    /// <summary>
    /// 套餐类型控制器-写入接口控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class PackageTypesController : ControllerBase
    {
        private readonly IMediator mediator;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediator">参数</param>
        public PackageTypesController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 新增套餐类型
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> AddPackageType(CreatePackageTypeCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 修改套餐类型
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> UpdatePackageType(UpdatePackageTypeCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        /// 删除套餐类型
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> DeletedPackageType([FromQuery]DeletedPackageTypeCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
